//
//  ReplyMineCellFrame.m
//  JiaoX
//
//  Created by yinqy on 15/2/27.
//  Copyright (c) 2015年 北京娇羞科技有限公司. All rights reserved.
//

#import "ReplyMineCellFrame.h"


@implementation ReplyMineCellFrame

-(instancetype)initWithReplyType:(NSString *)type
{
    self = [super init];
    if (self) {
        self.replyType = type;
    }
    return self;
}

-(void)setMineInteract:(MineInteract *)mineInteract{
    _mineInteract = mineInteract;
    
    CGFloat headImgX = JXPublicInset;
    CGFloat headImgY = 15;
    self.headImgFrame = CGRectMake(headImgX, headImgY, HEADIMG_WIDTH, HEADIMG_WIDTH);
    
    CGFloat nameLabelX = CGRectGetMaxX(self.headImgFrame)+5;
    CGFloat nameLabelY = CGRectGetMinY(self.headImgFrame);
    CGSize size = [mineInteract.userInfo.nickName sizeWithFont:[UIFont systemFontOfSize:NAMELABEL_FONT_SIZE]];
    self.nameLabelFrame = (CGRect){{nameLabelX, nameLabelY},size};
    
    CGFloat timeBtnX = nameLabelX;
    CGFloat timeBtnY = CGRectGetMaxY(self.nameLabelFrame)+10;
    CGFloat timeBtnW = JXScreenW-nameLabelX-JXPublicInset;
    CGFloat timeBtnH = [mineInteract.createTime sizeWithFont:[UIFont systemFontOfSize:TIMELABEL_FONT_SIZE]].height;
    self.timeLabelFrame = CGRectMake(timeBtnX, timeBtnY, timeBtnW, timeBtnH);
    
    CGFloat replyContentX = timeBtnX;
    CGFloat replyContentY = CGRectGetMaxY(self.headImgFrame)+JXPublicInset;
    CGSize replyContentSize = [mineInteract.content sizeWithFont:[UIFont systemFontOfSize:REPLYCONTENTLABEL_FONT_SIZE] constrainedToSize:CGSizeMake(JXScreenW-timeBtnX-JXPublicInset, MAXFLOAT)];
    self.replyContentFrame = (CGRect){{replyContentX,replyContentY},replyContentSize};
    
    CGFloat replyFromX = 12.5;
    CGFloat replyFromY = JXPublicInset;
    NSString *replyFrom = @"";
    if ([self.replyType isEqualToString:@"0"]) {
        replyFrom = [NSString stringWithFormat:@"回复我的帖子：%@",mineInteract.postsTitle];
    }else if([self.replyType isEqualToString:@"1"]){
        replyFrom = [NSString stringWithFormat:@"回复我的评论：%@",mineInteract.mainComment.commentContent];
    }
    CGSize replyFromSize = [replyFrom sizeWithFont:[UIFont systemFontOfSize:REPLYFROM_FONT_SIZE] constrainedToSize:CGSizeMake(timeBtnW-25, MAXFLOAT)];
    self.replyFromFrame = (CGRect){{replyFromX,replyFromY},replyFromSize};
    
    CGFloat replyFromBgX = replyContentX;
    CGFloat replyFromBgY = CGRectGetMaxY(self.replyContentFrame)+JXPublicInset;
    CGSize replyFromBgSize = CGSizeMake(timeBtnW, replyFromSize.height+JXPublicInset*2);
    self.replyFromBgFrame = (CGRect){{replyFromBgX,replyFromBgY},replyFromBgSize};
    
    self.frame = CGRectMake(0, 0, JXScreenW, CGRectGetMaxY(self.replyFromBgFrame)+JXPublicInset);
}
@end
